<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/WEB-INF/struts-tags.tld"%>
<%
String  module="checkbox";
if(request.getParameter("module")!=null&&!request.getParameter("module").equals("")){
	module=request.getParameter("module");
}
System.out.println("jsp module="+module);
 %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<base target="_self">
		<title>欢迎访问产品运营互动中心！</title>
		<link rel="stylesheet" href="<s:url value="/css/style.css"/>">
		<script type="text/javascript"
			src="<s:url value="/script/sysOper.js"/>"></script>
	</head>
	<body bgcolor="#FFFFFF" leftmargin="0" topmargin="0">
		<s:form action="/organ/listPersonTree.action" method="post">
			<input type="hidden" name="orgRelaPerson.organization.id"
				value="${orgRelaPerson.organization.id}">
			<table width="100%" border="0" cellspacing="0" cellpadding="0"
				background="<s:url value="/images/catalog_manage_8b.gif"/>">
				<tr>
					<td>
						<TABLE width="98%" border="0" cellspacing="0" cellpadding="0"
							align="center" class=tablecolor2>
							<tr>
								<td width="15%" height="50">
									姓名&nbsp;
									<input name="orgRelaPerson.person.name" type="text"
										value="${orgRelaPerson.person.name}" size="12" />
									&nbsp;
									<input type="button" name="search" onclick="submit();"
										value="查 询">
								</td>
							</tr>
						</TABLE>
						<input type="hidden" name="module"
							value="<%=module %>" />
						<input type="hidden" name="pageControl.usePage"
							value="${pageControl.usePage}" />
						<input type="hidden" name="pageControl.pageNo"
							value="${pageControl.pageNo}" />
						<input type="hidden" name="pageControl.totalPage"
							value="${pageControl.totalPage}" />
						<input type="hidden" name="pageControl.pageSize"
							value="${pageControl.pageSize}" />
						<table width="100%"  class="tablecolor2"  cellspacing="0" cellpadding="7"
							align="center" class="tablecolor2">
							<tr>
								<td align="right">
									<s:if test="pageControl.useFrontPage">
										<a href="#"
											onclick="document.all('pageControl.pageNo').value=${pageControl.pageNo-1};submit();">上一页</a>
									</s:if>
									<s:if test="pageControl.useNextPage">
										<a href="#"
											onclick="document.all('pageControl.pageNo').value=${pageControl.pageNo+1};submit();">下一页</a>
									</s:if>
									第${pageControl.pageNo}页 共${pageControl.totalPage}页
									总${pageControl.total}条记录 每页${pageControl.pageSize}条记录
								</td>
							</tr>
						</table>
						<table width="100%" border="0" cellspacing="0" cellpadding="7"
							align="center" class="tablecolor2">
							<tr>
								<td bgcolor="9AC2EB" width="45">
									<div align="center">
										<font color="#FFFFFF">
											选择
										</font>
									</div>
								</td>
								<td bgcolor="9AC2EB">
									<div align="center">
										<font color="#FFFFFF">人员 </font>
									</div>
								</td>
							</tr>
							<s:iterator value="pageControl.results">
								<tr>
									<td>
										<div align="center">
											<input type="<%=module %>" name="ids" 
												value="<s:property value='person.id' />"  onclick="selectPerson(this,'<s:property value="person.name" />');" >
											<input type="hidden" name="names" value="<s:property value='person.name' />"/>
										</div>
									</td>
									<td>
										<div align="center">
											<s:property value="person.name" />
										</div>
									</td>
								</tr>
							</s:iterator>
						</table>
			</table>
		</s:form>
	</body>
</html>
<script>
	function selectPerson(obj,nVal){
	          //alert(window.parent.document.getElementById("persons").innerHTML);
		var persons=window.parent.document.getElementById("persons").innerHTML;
		var personNames=window.parent.document.getElementById("personNames").innerHTML;
		if(obj.checked==true){
			persons+=obj.value+",";
			personNames+=nVal+",";
			insert(obj.value+",",nVal+",");
		}else{
			persons=(","+persons).replace(","+obj.value+",",",");
			persons=persons.substring(1,persons.length);
			personNames=(","+personNames).replace(","+nVal+",",",");
			personNames=personNames.substring(1,personNames.length);
			remove(obj.value+",");
		}
		if("<%=module%>"=="radio"){
			window.parent.document.getElementById("persons").innerHTML=obj.value+",";
			window.parent.document.getElementById("personNames").innerHTML=nVal+",";
			window.parent.document.getElementById("personDiv").style.display="none";
		}else{
			window.parent.document.getElementById("persons").innerHTML=persons;
			window.parent.document.getElementById("personNames").innerHTML=personNames;
		}
	}
window.attachEvent("onload", function(){
		var persons=window.parent.document.getElementById("persons").innerHTML;
		var ids=window.document.getElementsByName("ids");
		if(ids&&persons){
			for(var i=0;i<ids.length;i++){
				if(persons.indexOf(ids[i].value+",")!=-1){
					ids[i].checked=true;
				}
			}
		}
});

function insert(vId,vName){
	var tr=window.parent.document.getElementById('personNameTR');
	if(vId&&vId!=''){
		var newCell = tr.insertCell();
		newCell.id=vId;
		var str="<a href='#' onClick='delCell(";
		str+='"'+vId+'","'+vName+'");';
		str+="'>";
		str+=vName+'</a>';
		newCell.innerHTML=str;
	}
}

function remove(vId){
	var tr=window.parent.document.getElementById('personNameTR');
	var td=window.parent.document.getElementById(vId);
	if(td){
		tr.deleteCell(td.cellIndex);
	}
}
</script>